import axios from "axios";
//创建axios实例
const request = axios.create({
  baseURL: 'http://localhost:81/',
  timeout: 5000,
  headers: {
    "Content-Type": "application/json;charset=utf-8"
  }
})

//请求拦截
request.interceptors.request.use((config) => {
  return config
})


//响应拦截
request.interceptors.response.use((res) => {
  const code = res.status
  if (code != 200) { //如果不等于200 return
    return Promise.reject(res.data)
  }
  return res.data
}, (err) => {
  console.log(err);
})

export default request